<%@ page language="java" pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%>
<script type="text/javascript">
	$(function() {

		$('#admin_member_active_main_datagrid').datagrid({
			url : '${pageContext.request.contextPath}/memberController/listAllActiveMain.action',
			fit : true,
			fitColumns : true,
			border : false,
			pagination : true,
			idField : 'id',
			pageSize : 10,
			pageList : [ 10, 20, 30, 40, 50 ],
			sortName : 'createTime',
			sortOrder : 'desc',
			checkOnSelect : false,
			selectOnCheck : false,
			nowrap : false,
			frozenColumns : [ [ {
				field : 'id', title : '编号', checkbox : true}, {
				field : 'cardId', title : '卡号', sortable : true} ] ],
			columns : [ [ {
				field : 'name', title : '姓名', sortable : true}, {
				field : 'createTime', title : '创建时间', sortable : true}, {
				field : 'mobile', title : '手机号', sortable : true}, {
				field : 'email', title : '电子邮箱', sortable : true}, {
				field : 'statusName', title : '状态', sortable : true}, {
				field : 'memberTypeName', title : '会员类型', sortable : true}, {
				field : 'cid', title : '身份证号', sortable : true}, {
				field : 'genderName', title : '性别', sortable : true}, {
				field : 'payTypeName', title : '支付方式', sortable : true}, {
				field : 'regCharge', title : '缴费金额（元）', sortable : true, align : 'right'}, {
				field : 'memberFee', title : '会费（元）', sortable : true, align : 'right'}, {
				field : 'jifen', title : '积分', sortable : true, align : 'right'}, {
				field : 'balance', title : '消费余额（元）', sortable : true, align : 'right'}, {
				field : 'action1', title : '充值', align : 'center', formatter : function(value, row, index) {
				    return formatString('<img onclick="admin_member_recharge(\'{0}\');" src="{1}"/ title="充值">', row.id, '${pageContext.request.contextPath}/style/images/extjs_icons/pencil.png');
				}
			},
			]]
		});

	});

	function admin_member_active_main_searchFun() {
		$('#admin_member_active_main_datagrid').datagrid('load', serializeObject($('#admin_member_active_main_searchForm')));
	}
	
	function admin_member_active_main_cleanFun() {
		$('#admin_member_active_main_searchForm input').val('');
		$('#admin_member_active_main_datagrid').datagrid('load', {});
	}
	
	function admin_member_recharge(id) {
		$('#admin_member_active_main_datagrid').datagrid('uncheckAll').datagrid('unselectAll').datagrid('clearSelections');
		$('<div/>').dialog({
			href : '${pageContext.request.contextPath}/admin/member_recharge.jsp',
			width : 600,
			height : 500,
			modal : true,
			title : '会员充值',
			buttons : [ {
				text : '保存',
				iconCls : 'icon-edit',
				handler : function() {
					var formObj = $("#admin_member_rechargeForm");
					var recharge = formObj.find("input[name='recharge']");
					if(recharge.val() && recharge.val()==0) {
						$.messager.alert('错误','充值金额不能为0！');
						return;
					}
					var d = $(this).closest('.window-body');
					$('#admin_member_rechargeForm').form('submit', {
						url : '${pageContext.request.contextPath}/memberController/recharge.action',
						success : function(result) {
							try {
								var r = $.parseJSON(result);
								if (r.success) {
									$('#admin_member_active_main_datagrid').datagrid('reload');
									d.dialog('destroy');
								}
								$.messager.show({
									title : '提示',
									msg : r.msg
								});
							} catch (e) {
								$.messager.alert('提示', result);
							}
						}
					});
				}
			} ],
			onClose : function() {
				$(this).dialog('destroy');
			},
			onLoad : function() {
				var index = $('#admin_member_active_main_datagrid').datagrid('getRowIndex', id);
				var rows = $('#admin_member_active_main_datagrid').datagrid('getRows');
				var o = rows[index];
				$('#admin_member_rechargeForm').form('load', o);
			}
		});
	}
	
	
</script>
<div class="easyui-layout" data-options="fit : true,border : false">
	<div data-options="region:'north',title:'查询条件',border:false" style="height:200px" align="center">
		<form id="admin_member_active_main_searchForm">
			<table class="tableForm">
				<tr>
					<th style="width: 170px;">卡号(可模糊查询)</th>
					<td><input name="cardId" style="width: 315px;" /></td>
				</tr>
				<tr>
					<th style="width: 170px;">姓名(可模糊查询)</th>
					<td><input name="name" style="width: 315px;" /></td>
				</tr>
				<tr>
					<th style="width: 170px;">手机号(可模糊查询)</th>
					<td><input name="mobile" style="width: 315px;" /></td>
				</tr>
				<tr>
					<th>创建时间</th>
					<td><input name="createTimeStart" onFocus="WdatePicker({readOnly:true,dateFmt:'yyyy-MM-dd HH:mm:ss'})" />至<input name="createTimeEnd" onFocus="WdatePicker({readOnly:true,dateFmt:'yyyy-MM-dd HH:mm:ss'})" /></td>
				</tr>
			</table>
			<a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-search',plain:true" onclick="admin_member_active_main_searchFun();">过滤</a> <a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-cancel',plain:true" onclick="admin_member_active_main_cleanFun();">取消过滤</a>
		</form>
	</div>
	<div data-options="region:'center',border:false">
		<table id="admin_member_active_main_datagrid"></table>
	</div>
</div>